<!--
 * @Author: gyh
 * @Date: 2024-04-28 17:34:11
 * @LastEditTime: 2024-05-13 09:47:03
-->
<template>
  <view class="carousel">
    <swiper :circular="true" :autoplay="false" :interval="3000" @change="onChange">
      <swiper-item v-for="item in list" :key="item.id">
        <navigator url="/pages/index/index" hover-class="none" class="navigator">
          <image mode="aspectFill" class="image" :src="item.imgUrl"></image>
        </navigator>
      </swiper-item>
    </swiper>
    <!-- 指示点 -->
    <view class="indicator">
      <text
        v-for="(item, index) in list.length"
        :key="item"
        class="dot"
        :class="{ active: index === activeIndex }"
      ></text>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import type { bannerItem } from '@/types/home'

defineProps<{ list: bannerItem[] }>()

const activeIndex = ref(0),
  onChange: UniHelper.SwiperOnChange = (e) => {
    activeIndex.value = e.detail?.current
  }
</script>

<style lang="scss">
@import '@/components/styles/GyhSwiper.scss';
</style>
